'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  const jwtErr = middleware.jwtError({ ...app.config.jwt });

  // router.get('/', jwtErr, controller.home.index);
  router.post('/webtool/upload', jwtErr, controller.upload.index);
  router.post('/webtool/uploadfile', jwtErr, controller.upload.file);
  router.post('/webtool/login', controller.login.index);
  router.post('/webtool/logout', jwtErr, controller.user.logout);
  router.get('/webtool/user', jwtErr, controller.user.getUserInfo); // 获取用户信息
  router.get('/webtool/allusers', jwtErr, controller.user.getallUsers); // 获取全部用户信息

  router.resources('user', '/webtool/v1/user', controller.user);
  router.resources('store', '/webtool/v1/store', jwtErr, controller.store);
  router.resources('purchase', '/webtool/v1/purchase', jwtErr, controller.purchase);
  router.post('/webtool/v1/storebulkCreate', jwtErr, controller.store.storebulkCreate);
  router.get('/webtool/v1/storeexport', jwtErr, controller.store.storeexport);

  router.post('/webtool/v1/purchasebulkCreate', jwtErr, controller.purchase.purchasebulkCreate);
  router.get('/webtool/v1/purchaseexport', jwtErr, controller.purchase.purchaseexport);

  router.post('/webtool/v1/storemutipledestroy', jwtErr, controller.store.mutipledestroy);
  router.post('/webtool/v1/purchasemutipledestroy', jwtErr, controller.purchase.mutipledestroy);


};
